﻿// Author: AustralTek 
// Create date: 2010/05/04
// http://www.australtek.com
// Copyright: 2009 - 2010

(function () {
    function _ForeignConnection(options) {
        try{
            var privateParameters;            
            function _initialize(options){
                try{
                    privateParameters = new PrivateParameters(options);
                    privateParameters.Class ="ForeignConnection";
                }catch(Error){}
            };            
            function _AddConnection(fc){
                try{
                    var url = privateParameters.URL;
                    var options = {}; options.data = {};
                    options.data.action ='ADD';
                    options.data = fc;
                    options.data.Namespace = privateParameters.Version.Namespace;
                    options.data.Class = privateParameters.Version.Class;
                    options.onSuccess = function (message) {
                        //alert(message);                        
                    }
                    options.onFailure = function (message) {
                        //alert(message);
                    }
                    RequestJSON(url, options);
                }catch(Error){ privateParameters.Events.onError(Error); }
            };
            function _RemoveConnection(Name){
                try{

                }catch(Error){ privateParameters.Events.onError(Error); }
            }

            _initialize(options);           
            this.AddConnection=function(Name,ConnectionString){
                var fc={Name:Name,ConnectionString:ConnectionString};              
                _AddConnection(fc);
            };
            this.RemoveConnection=function(Name){
                _RemoveConnection(Name);
            };
        }catch(Error){}
    };
    window.ForeignConnection = function(options){return new _ForeignConnection(options)};
})();